package com.idbk.chargestation.view;

import android.content.Context;
import android.text.Html;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.idbk.chargestation.R;

public class ToastUtil {

	private static Toast mToast = null;  
	
	public static void showToast(Context context, String text, int duration) {
		if (mToast == null) {
			mToast = Toast.makeText(context, text, duration);
		} else {
			mToast.setText(text);
			mToast.setDuration(duration);
		}
		mToast.show();
	}

	/**
	 * toast取消
	 */
	public static void toastCancel() {

		if (mToast != null) {
			mToast.cancel();
			mToast = null;
		}
	}
    
//
//	public static void showWXToast(Context context, LayoutInflater inflater, String msg){
//		View layout = inflater.inflate(R.layout.toast_layout, null, false);
//
//		TextView text = (TextView) layout.findViewById(R.id.textview_toast_content);
//		text.setText(Html.fromHtml(msg));
//
//		Toast toast = new Toast(context.getApplicationContext());
//		toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
//		toast.setDuration(Toast.LENGTH_SHORT);
//		toast.setView(layout);
//		toast.show();
//	}
	
}
